﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<queue>
using namespace std;
#include"priority_queue.h"
//int main()
//{
//	Yuey::priority_queue<int,vector<int>,Greater<int>> pq;
//	//Yuey::priority_queue<int> pq;
//	//priority_queue<int> pq;
//	if (pq.empty())
//	{
//		cout << "空的优先级队列" << endl;
//	}
//	pq.push(1);
//	pq.push(1314);
//	pq.push(2);
//	pq.push(520);
//	while (!pq.empty())
//	{
//		cout << pq.top() << " ";
//		pq.pop();
//	}
//	cout << endl;
//}
//template<class T,class Compare>
//void Bubblesort(T* a, size_t n, Compare com)
//{
//	for (int j = 0; j < n - 1; j++)
//	{
//		// 单趟
//		int flag = 0;
//		for (int i = 1; i < n - j; i++)
//		{
//			//if (a[i] < a[i - 1])
//			if (com(a[i], a[i - 1]))
//			{
//				swap(a[i - 1], a[i]);
//				flag = 1;
//			}
//		} 
//		if (flag == 0)
//		{
//			break;
//		}
//	}
//}
//int main()
//{
//	int a[] = { 1,4,6,7,5,3,3,9 };
//	Bubblesort(a, 8, Less<int>());
//	Bubblesort(a, 8, Greater<int>());
//	return 0;
//}
class Date
{
public:
	Date(int year = 1900, int month = 1, int day = 1)
		: _year(year)
		, _month(month)
		, _day(day)
	{}

	bool operator<(const Date& d)const
	{
		return (_year < d._year) ||
			(_year == d._year && _month < d._month) ||
			(_year == d._year && _month == d._month && _day < d._day);
	}

	bool operator>(const Date& d)const
	{
		return (_year > d._year) ||
			(_year == d._year && _month > d._month) ||
			(_year == d._year && _month == d._month && _day > d._day);
	}

	friend ostream& operator<<(ostream& _cout, const Date& d)
	{
		_cout << d._year << "-" << d._month << "-" << d._day;
		return _cout;
	}

private:
	int _year;
	int _month;
	int _day;
};
struct LessDate
{
	bool operator()(Date* d1, Date* d2)
	{
		return *d1 < *d2;
	}
};
int main()
{
	std::priority_queue<Date,vector<Date>,less<Date>> q1;
	q1.push(Date(2024, 11, 22));
	q1.push(Date(2024, 11, 23));
	q1.push(Date(2024, 11, 24));
	while (!q1.empty())
	{
		cout << q1.top() << " " << endl;
		q1.pop();
	}
	cout << endl;
	std::priority_queue<Date*, vector<Date*>, LessDate> q2;
	q2.push(new Date(2024, 11, 22));
	q2.push(new Date(2024, 11, 23));
	q2.push(new Date(2024, 11, 24));
	while (!q2.empty())
	{
		cout << *(q2.top()) << " " << endl;
		q2.pop();
	}
	return 0;
}
